package com.iwomy.secureplat.platform.service.impl;

import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.iwomy.secureplat.platform.entity.AlarmEventTypeEntity;
import com.iwomy.secureplat.platform.entity.BasicDeviceEntity;
import com.iwomy.secureplat.platform.enumeration.StateEnum;
import com.iwomy.secureplat.platform.mapper.AlarmEventTypeMapper;
import com.iwomy.secureplat.platform.service.AlarmEventTypeService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 报警事件类型
 *
 * @author pig
 * @date 2023-12-22 19:21:52
 */
@Service
public class AlarmEventTypeServiceImpl extends ServiceImpl<AlarmEventTypeMapper, AlarmEventTypeEntity> implements AlarmEventTypeService {
	@Override
	public List<AlarmEventTypeEntity> listByBasicDeviceAndCode(BasicDeviceEntity basicDeviceEntity
			, String alarmTypeCode, String eventTypeCode, String protocolName) {
		LambdaQueryWrapper<AlarmEventTypeEntity> queryWrapper = Wrappers.lambdaQuery();
		queryWrapper.eq(AlarmEventTypeEntity::getProtocolName, protocolName);
		queryWrapper.eq(AlarmEventTypeEntity::getState, StateEnum.ENABLE.getVal());
		queryWrapper.eq(AlarmEventTypeEntity::getAlarmTypeCode, alarmTypeCode);
		queryWrapper.eq(ObjectUtil.isNotEmpty(eventTypeCode), AlarmEventTypeEntity::getEventTypeCode, eventTypeCode);
		return this.list(queryWrapper);
	}

}